<?php

require_once "include/config.php";
require_once "include/functions.php";

$cols = read_module_option('random_videos', 'columns');
$rows = read_module_option('random_videos', 'rows');

$total = $cols * $rows;
$divs_hspace = 100 / $cols;
$random_videos = get_random_videos($total);

$table_random_videos =
"
    <style>
    div.rvimg
    {
	border-color: #d3d3d3;
	border-style: solid ;
	border-width: 1px;
	width: 120px;
	height: 90px;
    padding: 3px;
	-moz-border-radius:3px;  /* for Firefox */
	-webkit-border-radius:3px; /* for Webkit-Browsers */
	border-radius:3px; /* regular */
    }
    </style>
    
	<style>
	#modrv-container {text-align: center;}
	</style>
	
	
    <center>
    
    <div id='modrv-container' style='width:100%;'>

";
$counter = 0;
for ($i = 0; $i <= count($random_videos)-1; $i++) {
$counter = $counter + 1;
$video_title = $random_videos[$i]['name'];
$image2 = $random_videos[$i]['image2'];
$video_id = $random_videos[$i]['id'];

if($counter=='1')
{
$table_random_videos = $table_random_videos . "
<div class='modrvrow-container' style='clear:both; width:100%;'>
";
}

$table_random_videos = $table_random_videos . "
<div class='modrv-block' style='float:left; width:".$divs_hspace."%; text-align: center;'>

<div style='width:120px; margin-left:auto; margin-right:auto;'>

<div class='rvimg'>
<a href='index.php?page=video_player&video_id=$video_id'><img src='thumbnails/".$image2."' alt='".$video_title."' style='width:120px; height:90px;'></a>
</div>
<div>".$video_title."</div>

</div>

</div>
";

if($counter==$cols)
{
$table_random_videos = $table_random_videos . "</div>";
$counter = 0;
}

}

$table_random_videos = $table_random_videos . "
</div>
</center>
<div style='clear:both;'></div>
";
?>

